#pragma once

#include "types.h"
#include <windows.h>

namespace sol9
{

	class chrono
	{
		class clock
		{
		private:
			LARGE_INTEGER freq;

		public:
			clock()
			{
				QueryPerformanceFrequency(&freq);
			}

			LONGLONG time()
			{
				LARGE_INTEGER t;
				QueryPerformanceCounter(&t);

				return t.QuadPart * 1000 / freq.QuadPart;
			}
		};

	private:
		clock c;

	public:
		u32 time()
		{
			return (u32)c.time();
		}

		u32 tick()
		{
			static u32 prev = time();
			u32 curr = time();

			u32 tick = curr - prev;
			prev = curr;

			return tick;
		}
	};

} // namespace sol9